package test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author oldliu
 * @since 1.0
 */
public class QuizDate {
    public static void main(String[] args) throws ParseException {
        //学士后结业考试的时间是每月倒数第二个周六上午8点，输出今年的考试时间
        //，用yyyy/MM/dd hh时 的格式输出
        Calendar c=Calendar.getInstance();
        int year=c.get(Calendar.YEAR);
        c.set(year,Calendar.JANUARY,1,8,0,0);
        //c.set(Calendar.,Calendar.SATURDAY);
//        for(int i=1;i<=12;i++){
//            String str=year+"-"+i+" -2";
//        }
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM F");
        String str="2023-8 -2";
        Date date = df.parse(str);
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK,Calendar.SATURDAY);
        Calendar c2=Calendar.getInstance();
        c2.setTime(c.getTime());
        c2.set(Calendar.DATE,c2.getActualMaximum(Calendar.DATE));
        if(c2.get(Calendar.DAY_OF_WEEK)!=Calendar.SATURDAY)
            c.add(Calendar.DATE,-7);
        System.out.println(c.getTime());
    }
}
